local skel = fk.CreateSkill{
  name = "tea__zhenqu__duel_skill",
}
--local U = require "packages/utility/utility"
Fk:loadTranslationTable{
  ["tea__zhenqu__duel_skill"] = "决斗",
  [":tea__zhenqu__duel_skill"] = "振躯决斗",
  ["#ZhenquAskForDistributeMultiCard"] = "请分配【%arg】（此为第 %arg2 张，共需 %arg3 张）",
}
---@type TrigSkelSpec<DamageTrigFunc>
skel:addEffect("cardskill", {
  prompt = "#duel_skill",
  mod_target_filter = function(self, player, to_select, selected, card)
    return to_select ~= player
  end,
  target_filter = Util.CardTargetFilter,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = effect.to
    local from = effect.from
    local responsers = { to, from }
    local currentTurn = 1
    local currentResponser = to

    while currentResponser:isAlive() do
      local loopTimes = 1 --专有牌锁一下

      local targets, cards, respond
      for i = 1, loopTimes do
        local tochoose = table.filter(room.alive_players, function(p)
          local another = responsers[currentTurn % 2 + 1]
          return p ~= currentResponser and p ~= another
        end)
        if #tochoose == 0 then break end
        targets, cards, respond = room:askToChooseCardsAndPlayers(currentResponser, {
          min_card_num = 1,
          max_card_num= 1,
          min_num = 1,
          max_num = 1,
          skill_name = skel.name,
          targets = tochoose,
          pattern = "jink",
          prompt = "#ZhenquAskForDistributeMultiCard:::jink:"..i..":"..loopTimes
        })
        if respond and #targets == 1 and #cards == 1 then
          room:doIndicate(currentResponser, targets)
          room:doYiji({ [targets[1].id] = cards }, currentResponser, skel.name)
        else
          break
        end
      end

      if not respond then
        break
      end

      currentTurn = currentTurn % 2 + 1
      currentResponser = responsers[currentTurn]
    end

    if currentResponser:isAlive() then
      room:damage({
        from = responsers[currentTurn % 2 + 1],
        to = currentResponser,
        card = effect.card,
        damage = 1,
        damageType = fk.NormalDamage,
        skillName = skel.name,
      })
    end
  end,
})
--Fk.generals["mouxusheng"]:addSkill(skel.name)
return skel